package com.info.zhiduoduo.repository.mapper.quota;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Condition;
import com.info.zhiduoduo.repository.dto.quota.CrowdsourceCityQuotaDto;
import com.info.zhiduoduo.repository.entity.quota.CrowdsourceCityQuota;

import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author bob
 * @since 2020-11-01
 */
public interface CrowdsourceCityQuotaMapper extends BaseMapper<CrowdsourceCityQuota> {

	default boolean deleteByConfigId(int configId) {
		return new CrowdsourceCityQuota().delete(Condition.create().eq("config_id", configId));
	}

	@Select(" select * from zdd_crowdsource_city_quota " +
			" where config_id = #{configId} and user_type = #{userType} and deleted = 0")
	CrowdsourceCityQuota getByConfigIdAndUserType(int configId, int userType);

	@Select(" select id,user_type,cs_once_quota,cs_monthly_quota,cs_yearly_quota,config_id,cs_quarterly_quota " +
			" from zdd_crowdsource_city_quota " +
			" where config_id = #{id} and deleted = 0 ")
	List<CrowdsourceCityQuotaDto> listByConfigId(Integer id);
}
